/*
 * The National Parks Database Project
 * Group: Tyler Simrell, Vladmir Dudnic, Michael Jagielo
 * MainFrame.java
 */

package gui;


import java.awt.CardLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import panels.AddPanel;
import panels.CheckStatusPanel;
import panels.HikerPanel;
import panels.MaintenancePanel;
import panels.ResultsPanel;
import panels.UpdateDBPanel;
import panels.WelcomePanel;

/**
 * This class is the basis of the National Parks Database program. Here is where the GUI is created and where
 * the GUI works with the database backend.
 * @author Tyler Simrell
 * @version 5/24/13
 *
 */
@SuppressWarnings("serial")
public class MainFrame extends JFrame 
{
	public static final String MAINTENANCE_PANEL = "maintenancePanel";
	public static final String HIKING_PANEL = "hikerPanel"; 
	public static final String RESULTS_PANEL = "resultsPanel";
	public static final String CHECK_STATUS_PANEL = "checkStatusPanel";
	public static final String UPDATE_DB_PANEL = "updateDBPanel";
	public static final String ADD_DB_PANEL = "addDBPanel";
	public static final String WELCOME_PANEL = "welcomePanel";
	
	
	private JPanel cardPanel;
	private CardLayout cards;
	public final static String DIFFICULTY_LEVELS[] = {"Easy", "Medium", "Hard"};
	public final static String TERRAIN_TYPES[] = {"Forest", "Meadow"};
	
	private JTextField updateTrailField;
	private UpdateDBPanel updateDBPanel;
	private JLabel updateLabel;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) 
	{
		new MainFrame();
		//String[] data = {"The Giant Trail", "The Hoh Rain Forest", "The River", "12", "6", "Forest", "Hard"};
		//System.out.println(FieldParser.parseFields(data));
	}

	/**
	 * Create the frame.
	 */
	public MainFrame() 
	{
		setUp();
	}
	
	/**
	 * Set up much of the work that has to get done, including creating all of the panels and 
	 * appending to the list of cards.
	 */
	private void setUp()
	{
		setTitle("National Parks Trail Database");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setVisible(true);
		setBounds(100, 100, 860, 600);
		setResizable(false);
		getContentPane().setLayout(null);
		cardPanel = new JPanel();
		cardPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(cardPanel);
		cards = new CardLayout();
		cardPanel.setLayout(cards);
		
		updateTrailField = new JTextField();
		updateLabel = new JLabel();
		CheckStatusPanel csp = new CheckStatusPanel(cards, cardPanel);
		ResultsPanel resultPanel = new ResultsPanel(cards, cardPanel);
		
		cardPanel.add(new WelcomePanel(cards, cardPanel));
		cardPanel.add(new HikerPanel(cards, cardPanel, resultPanel));
		updateDBPanel = new UpdateDBPanel(cards, cardPanel, updateLabel);
		cardPanel.add(updateDBPanel);
		cardPanel.add(new MaintenancePanel(cards, cardPanel, updateTrailField, updateLabel, updateDBPanel, csp));
		cardPanel.add(resultPanel);
		cardPanel.add(csp);
		cardPanel.add(new AddPanel(cards, cardPanel));
		
		cards.show(cardPanel, "welcomePanel");
	}
}